<div class="HelpDiv">
	<div class="HelpDivHead">
		<div class="HelpTitle">Entity</div>
		<div class="HelpMenu">
		  <div><a href="#Introduce">功能介绍</a></div>
		  <div><a href="#Property">属性</a></div>
		  <div><a href="#Function">方法</a></div>
		</div>
	</div>

	<div class="HelpBody">
		<div>
			<div id="Introduce" class="HelpBodyBig">功能介绍</div>
			<div class="HelpBodyMiddle">
				1，后台实体类，统一数据库操作，禁止用其他方法操作数据库;<br>
				2，对批量提交数据提供事务回滚功能;<br>
				3，乐观锁控制记录修改，避免脏写;<br>
				4，提供外键功能;<br>
				   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;需在ReferenceRelation里面设置，例如：ItemMaster被MO的ItemMaster字段引用，如果删除ItemMaster将会有校验，代码设置如下：<br>
				   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ItemMaster: {MO: ['ItemMaster']}<br>
				5，查询条件支持正则表达式，以"\...\"传入过来字符串查询条件，将会作为正则表达式来处理;<br>
				6，服务器在启动时会自动为每张表创建一个实体类，开发过程中无须重新new一个副本，EntityCollection.getEntity('实体名称');<br>
				7，扩展查询条件功能，比如：查找料品编码为“XXX”的生产订单时，可将条件写为：{"ItemMaster.Code": 'XXX'}。
			</div>
			<div class="HelpBodyMiddle">注意：Entity操作的每一条Record都有如下公共属性（继承基类BaseModel），系统会自动维护这些属性</div>
			<div class="HelpBodySmall">
				<div>SysVersion</div>
				<div>记录版本</div>
			</div>
			<div class="HelpBodySmall">
				<div>CreatedOn</div>
				<div>创建时间</div>
			</div>
			<div class="HelpBodySmall">
				<div>CreatedBy</div>
				<div>创建人</div>
			</div>
			<div class="HelpBodySmall">
				<div>ModifyOn</div>
				<div>修改时间</div>
			</div>
			<div class="HelpBodySmall">
				<div>ModifyBy</div>
				<div>修改人</div>
			</div>
		</div>

		<br>
		<div>
			<div id="Property" class="HelpBodyBig">属性</div>
			<div class="HelpBodySmall">
				<div>EntityName</div>
				<div>实体名（数据库表名称）</div>
			</div>
			<div class="HelpBodySmall">
				<div>Name</div>
				<div>实体中文名，方便自动提示错误信息</div>
			</div>
			<div class="HelpBodySmall">
				<div>Parent</div>
				<div>类型：entityClass，主子关系表，父实体</div>
			</div>
			<div class="HelpBodySmall">
				<div>Childs</div>
				<div>类型：Array(entityClass)，主子关系，子实体集合</div>
			</div>
			<div class="HelpBodyMiddle">代码</div>
			<div class="HelpBodySmall">
				<div>创建</div>
				<div>new entityClass('表名', '中文名')，业务开发过程中基本用不到</div>
			</div>
			<div class="HelpBodySmall">
				<div>获取</div>
				<div>EntityCollection.getEntity(EntityName)</div>
			</div>
		</div>

		<br>
		<div>
			<div id="Function" class="HelpBodyBig">方法</div>
			<div class="HelpBodyMiddle">公共参数</div>
			<div class="HelpBodySmall">
				<div class="HelpNotEmpty">callback</div>
				<div>
					因为所有方法都是异步调用操作数据库，所以都会有一个回调方法用来接收异步调用后的返回结果;<br>
					callback(err, data)，err：若有值，表示操作出错，data：操作正确后的返回结果。
				</div>
			</div>

			<br>
			<div class="HelpBodyMiddle">save(records, callback)，根据行状态（增、删、改）保存数据集合，批量保存会有事务回滚处理</div>
			<div class="HelpBodySmall">
				<div class="HelpNotEmpty">records</div>
				<div>需要持久化的记录集</div>
			</div>
			<br>
			<div class="HelpBodyMiddle">insert(record, callback)，新增单条记录</div>
			<div class="HelpBodySmall">
				<div class="HelpNotEmpty">record</div>
				<div>新增记录</div>
			</div>
			<br>
			<div class="HelpBodyMiddle">delete(condition, callback)，按条件删除记录</div>
			<div class="HelpBodySmall">
				<div>condition</div>
				<div>删除条件，例如：{Code: 'XXX'}</div>
			</div>
			<br>
			<div class="HelpBodyMiddle">deleteById(id, callback)，根据_id删除记录</div>
			<div class="HelpBodySmall">
				<div class="HelpNotEmpty">id</div>
				<div>Record._id</div>
			</div>
			<br>
			<div class="HelpBodyMiddle">deleteByIds(ids, callback)，根据行_id集合删除记录</div>
			<div class="HelpBodySmall">
				<div class="HelpNotEmpty">ids</div>
				<div>Record._id数组</div>
			</div>
			<br>
			<div class="HelpBodyMiddle">update(record, callback)，修改单条记录</div>
			<div class="HelpBodySmall">
				<div class="HelpNotEmpty">record</div>
				<div>修改后的记录</div>
			</div>
			<br>
			<div class="HelpBodyMiddle">updateByValue(condition, value, callback)，根据条件批量修改记录</div>
			<div class="HelpBodySmall">
				<div>condition</div>
				<div>查询条件</div>
			</div>
			<div class="HelpBodySmall">
				<div class="HelpNotEmpty">value</div>
				<div>修改内容，例如：{Name: 'XXX'}</div>
			</div>
			<br>
			<div class="HelpBodyMiddle">find(condition, orderBy, populate, callback)，查找记录</div>
			<div class="HelpBodySmall">
				<div>condition</div>
				<div>查询条件</div>
			</div>
			<div class="HelpBodySmall">
				<div>orderBy</div>
				<div>结果排序条件，例如：{Code: -1}</div>
			</div>
			<div class="HelpBodySmall">
				<div>populate</div>
				<div>关联展开子实体，实体字段必须是Schema.ObjectId类型，例如：{path: 'Department', select: 'Code Name'}</div>
			</div>
			<br>
			<div class="HelpBodyMiddle">findById(id, populate, callback)，根据_id查找记录</div>
			<div class="HelpBodySmall">
				<div class="HelpNotEmpty">id</div>
				<div>Record._id</div>
			</div>
			<div class="HelpBodySmall">
				<div>populate</div>
				<div>关联展开子实体，实体字段必须是Schema.ObjectId类型，例如：{path: 'Department', select: 'Code Name'}</div>
			</div>
			<br>
			<div class="HelpBodyMiddle">findOne(condition, populate, callback)，修改单条记录</div>
			<div class="HelpBodySmall">
				<div>condition</div>
				<div>查询条件</div>
			</div>
			<div class="HelpBodySmall">
				<div>populate</div>
				<div>关联展开子实体，实体字段必须是Schema.ObjectId类型，例如：{path: 'Department', select: 'Code Name'}</div>
			</div>
			<br>
			<div class="HelpBodyMiddle">search(text, filter, limit, callback)，全文检索记录，本查询需开启数据库全文检索功能</div>
			<div class="HelpBodySmall">
				<div class="HelpNotEmpty">text</div>
				<div>需要检索的文本</div>
			</div>
			<div class="HelpBodySmall">
				<div class="HelpNotEmpty">filter</div>
				<div>过滤条件，例如：{Code: 'XXX'}</div>
			</div>
			<div class="HelpBodySmall">
				<div>limit</div>
				<div>返回限制条数</div>
			</div>
			<br>
			<div class="HelpBodyMiddle">pageQuery(condition, orderBy, populate, pageNum, pageSize, callback)，按页查找记录</div>
			<div class="HelpBodySmall">
				<div>condition</div>
				<div>查询条件</div>
			</div>
			<div class="HelpBodySmall">
				<div>orderBy</div>
				<div>结果排序条件，例如：{Code: -1}</div>
			</div>
			<div class="HelpBodySmall">
				<div>populate</div>
				<div>关联展开子实体，实体字段必须是Schema.ObjectId类型，例如：{path: 'Department', select: 'Code Name'}</div>
			</div>
			<div class="HelpBodySmall">
				<div>orderBy</div>
				<div>结果排序条件，例如：{Code: -1}</div>
			</div>
			<div class="HelpBodySmall">
				<div class="HelpNotEmpty">pageNum</div>
				<div>页号，从0开始</div>
			</div>
			<div class="HelpBodySmall">
				<div class="HelpNotEmpty">pageSize</div>
				<div>每页条数</div>
			</div>
			<br>
			<div class="HelpBodyMiddle">queryRecordCount(condition, callback)，查询记录条数</div>
			<div class="HelpBodySmall">
				<div>condition</div>
				<div>查询条件</div>
			</div>
			<br>
			<div class="HelpBodyMiddle">findRecordIndex(id, condition, orderBy, callback)，根据条件查找记录所在的位置</div>
			<div class="HelpBodySmall">
				<div class="HelpNotEmpty">id</div>
				<div>Record._id</div>
			</div>
			<div class="HelpBodySmall">
				<div>condition</div>
				<div>查询条件</div>
			</div>
		</div>
	</div>
</div>